﻿using System;
using System.Collections.Generic;

namespace SmartFront.Toolkit.Core
{
    /// <summary>
    /// Interface implemented by <see cref="DependencyInjectionFactory{TFactory,T}"/>.
    /// </summary>
    /// <typeparam name="T">The type which the factory is creating</typeparam>
    public interface IDependencyInjectionFactory<T>
    {
        /// <summary>
        /// Gets the dependencies used for dependency injection.
        /// </summary>
        /// <value>The dependencies.</value>
        IDictionary<DependencyResolutionLocatorKey, object> Dependencies
        {
            get;
        }

        /// <summary>
        /// Adds the dependency to the list of dependencies injected into the type
        /// being created.
        /// </summary>
        /// <param name="dependencyType">Type of the dependency.</param>
        /// <param name="name">The name.</param>
        /// <param name="value">The value.</param>
        void AddDependency(Type dependencyType, string name, object value);

        /// <summary>
        /// Removes all dependencies which have been added by <see cref="AddDependency"/>
        /// </summary>
        void ResetDependencies();

        /// <summary>
        /// Creates an instance of <typeparamref name="T"/>.
        /// </summary>
        /// <returns>Newly created <typeparamref name="T"/></returns>
        T Create();

        /// <summary>
        /// Creates an instance of <typeparamref name="T"/>.
        /// </summary>
        /// <param name="locatorKey">The key to use to lookup a registered object in the locator.</param>
        /// <returns>Newly created <typeparamref name="T"/></returns>
        T Create(string locatorKey);
    }
}
